﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

public partial class BaseManage_EditPointSetting :Frame.Pages.BasePage
{
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!IsPostBack && !IsCallback)
        {
            //构建LTS数据上下文
            using (DAL.CMSDALDataContext Dcontext = new DAL.CMSDALDataContext())
            {
                BI_SysSettings sysSetting = Dcontext.BI_SysSettings.FirstOrDefault(o => o.SettingName == "PonitChangeValue");
                if (sysSetting == null)
                {
                    sysSetting = new BI_SysSettings()
                    {
                        SettingName = "PonitChangeValue",
                        Value = "1",
                        Remark = "消费金额兑换积分基数"
                    };
                    Dcontext.BI_SysSettings.InsertOnSubmit(sysSetting);
                    Dcontext.SubmitChanges();
                }
                tbxMoney.Text = sysSetting.Value;
            }
        }

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //构建LTS数据上下文
        using (DAL.CMSDALDataContext Dcontext = new DAL.CMSDALDataContext())
        {
            BI_SysSettings sysSetting = Dcontext.BI_SysSettings.FirstOrDefault(o => o.SettingName == "PonitChangeValue");
            if (sysSetting == null)
            {
                sysSetting = new BI_SysSettings()
                {
                    SettingName = "PonitChangeValue",
                    Value = tbxMoney.Text,
                    Remark = "消费金额兑换积分基数"
                };
                Dcontext.BI_SysSettings.InsertOnSubmit(sysSetting);
            }
            else
            {
                sysSetting.Value = tbxMoney.Text;
            }
            Dcontext.SubmitChanges();
        }
        Frame.Global.GlobalFunctions.Alert("提交修改成功！");
    }

    protected override string ActionID
    {
        get { return "0"; }
    }
}